package top.lyjwn.todo.weinxin.applet;

import com.alibaba.fastjson2.JSONException;
import com.alibaba.fastjson2.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.lyjwn.todo.weinxin.data.error.WxError;

import java.util.Date;

/**
 * 微信小程序_基础_access_token
 *
 * @author luoyujie
 *
 */
public class AppletAccessToken  {

	private static final Logger log = LoggerFactory.getLogger("error");

	/**
	 * 获取到的凭证
	 */
	private String access_token;

	/**
	 * 凭证有效时间，单位：秒。目前是7200秒之内的值。
	 */
	private long expires_in;

	private String errcode;

	private String errmsg;

	private Date acquisitionTime;


	public AppletAccessToken() {
	}

	public AppletAccessToken(String access_token, long expires_in) {
		this.access_token = access_token;
		this.expires_in = expires_in;
	}

	public static AppletAccessToken builder(JSONObject jsonObject) {
		try {
			return jsonObject.toJavaObject(AppletAccessToken.class);
		} catch (JSONException e) {
			log.error("AccessToken 转换失败"+jsonObject.toJSONString(), e);
		}
		return null;
	}

	public String getAccess_token() {
		return access_token;
	}

	public void setAccess_token(String access_token) {
		this.access_token = access_token;
	}

	public long getExpires_in() {
		return expires_in;
	}

	public void setExpires_in(long expires_in) {
		this.expires_in = expires_in;
	}

	public String getErrcode() {
		return errcode;
	}

	public void setErrcode(String errcode) {
		this.errcode = errcode;
	}

	public String getErrmsg() {
		return errmsg;
	}

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	public Date getAcquisitionTime() {
		return acquisitionTime;
	}

	public void setAcquisitionTime(Date acquisitionTime) {
		this.acquisitionTime = acquisitionTime;
	}
}
